<include file="header" />
    <div class="swiper-container kv">
        <div class="swiper-wrapper">
            <div class="swiper-slide kv_6">
                <img class="ani logoImg" src="__PUBLIC__/images/logo.png"/>
                <img class="kv_img" src="__PUBLIC__/images/kv_img_1.png"/>
                <img class="imgNew2" src="__PUBLIC__/images/upimg.jpg"/>
                <label class="upBtn">
                    <span>上传照片</span>
                    <input type="file" id="pic" name="pic" onchange="upload_img('pic', 500, 500)" />
                </label>
            </div>
        </div>
    </div>
    <input type="hidden" id="picVal" value="" />
    <!-- layer引入开始 -->
    <script src="__PUBLIC__/layer/mobile/layer.js"></script>
    <script>
        //信息提示框
        function malert(msg,time){
            var durationTime = time ? time : 1.5;
            layer.open({content:msg,time:durationTime});
        }
        //加载动画
        function mload(){
            layer.open({type:2,shadeClose:false});
        }
    </script>
    <!-- layer引入结束 -->
    <!-- 上传图片开始 -->
    <script type='text/javascript' src='__PUBLIC__/js/ajaxfileupload.js'></script>
    <script type="text/javascript">
        //width height 要压缩成的图片宽 高，默认0代表不限制
        function upload_img(id, width, height){
            if(id == '' || id == null) return;
            if(!width) width = 0;
            if(!height) height = 0;

            mload();
            $.ajaxFileUpload ({
                 url: "<{:U('Admin/PicUpload/index')}>",
                 data: {width: width, height: height},
                 secureuri: false,
                 fileElementId: id,
                 dataType: 'json',
                 success: function (data, status) {
                    layer.closeAll();
                    if(data.status){
                        $('#picVal').val(data.info);

                        //保存照片数据
                        $.get("<{:U('photos_add')}>", {pic : data.info}, function (res) {
                            if (res.status == 0) {
                                malert(res.info);
                            } else {
                                location.href="<{:U('confirm_view')}>&photos_id="+res.info;
                            }
                        }, 'json')
                    }else{
                        malert(data.info);
                    }
                 }
            });
        }
    </script>
    <!-- 上传图片结束 -->
    <script> 
        var mySwiper = new Swiper('.swiper-container',{
            direction : 'vertical',
            width : window.innerWidth,
            height : window.innerHeight,
            onInit: function(swiper){ //Swiper2.x的初始化是onFirstInit
                swiperAnimateCache(swiper); //隐藏动画元素 
                swiperAnimate(swiper); //初始化完成开始动画
            }
        });
    </script>
<include file="footer" />